home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / winsock / ws_ping.zip / WSPI_SRC.ZIP / WS_ERROR.C < prev    next >
C/C++ Source or Header  |  1994-01-20  |  4KB  |  144 lines

  1. /***************************************************************************
  2.   Windows Sockets Client Application Support Module
  3.  
  4.   Written by:
  5.       John A. Junod             Internet: <junodj@css583.gordon.army.mil>
  6.       267 Hillwood Street                 <zj8549@trotter.usma.edu>
  7.       Martinez, GA 30907      Compuserve: 72321,366 
  8.  
  9.   This program executable and all source code is released into the public
  10.   domain.  If you use this code in your program, the following statement
  11.   must be included in your source code and in the documentation:
  12.  
  13.   *****  This program uses source code written by John A. Junod.  ******
  14.  
  15.   THE INFORMATION AND CODE PROVIDED IS PROVIDED AS IS WITHOUT WARRANTY 
  16.   OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  17.   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  18.   PURPOSE. IN NO EVENT SHALL JOHN A. JUNOD BE LIABLE FOR ANY DAMAGES 
  19.   WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS 
  20.   OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF JOHN A. JUNOD HAS BEEN 
  21.   ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  22.  
  23. *****************************************************************************/
  24.  
  25. #include "ws_glob.h"
  26. #include "ws_ping.h"
  27.  
  28. LPSTR ReturnWSError(UINT nErr,LPSTR lpszBuf)
  29. {
  30.   static char szErrMsg[128];
  31.   LPSTR lpszRetStr;
  32.  
  33.   switch(nErr)
  34.   {
  35.     case WSAVERNOTSUPPORTED:
  36.       lpszRetStr="version of WinSock not supported";
  37.       break;
  38.     case WSASYSNOTREADY:
  39.       lpszRetStr="WinSock not present or not responding";
  40.       break;
  41.     case WSAEINVAL:
  42.       lpszRetStr="app version not supported by DLL";
  43.       break;
  44.     case WSAHOST_NOT_FOUND:
  45.       lpszRetStr="Authoritive: Host not found";
  46.       break;
  47.     case WSATRY_AGAIN:
  48.       lpszRetStr="Non-authoritive: host not found or server failure";
  49.       break;
  50.     case WSANO_RECOVERY:
  51.       lpszRetStr="Non-recoverable: refused or not implemented";
  52.       break;
  53.     case WSANO_DATA:
  54.       lpszRetStr="Valid name, no data record for type";
  55.       break;
  56. /*
  57.     case WSANO_ADDRESS:
  58.       lpszRetStr="Valid name, no MX record";
  59.       break;
  60. */
  61.     case WSANOTINITIALISED:
  62.       lpszRetStr="WSA Startup not initialized";
  63.       break;
  64.     case WSAENETDOWN:
  65.       lpszRetStr="Network subsystem failed";
  66.       break;
  67.     case WSAEINPROGRESS:
  68.       lpszRetStr="Blocking operation in progress";
  69.       break;
  70.     case WSAEINTR:
  71.       lpszRetStr="Blocking call cancelled";
  72.       break;
  73.     case WSAEAFNOSUPPORT:
  74.       lpszRetStr="address family not supported";
  75.       break;
  76.     case WSAEMFILE:
  77.       lpszRetStr="no file descriptors available";
  78.       break;
  79.     case WSAENOBUFS:
  80.       lpszRetStr="no buffer space available";
  81.       break;
  82.     case WSAEPROTONOSUPPORT:
  83.       lpszRetStr="specified protocol not supported";
  84.       break;
  85.     case WSAEPROTOTYPE:
  86.       lpszRetStr="protocol wrong type for this socket";
  87.       break;
  88.     case WSAESOCKTNOSUPPORT:
  89.       lpszRetStr="socket type not supported for address family";
  90.       break;
  91.     case WSAENOTSOCK:
  92.       lpszRetStr="descriptor is not a socket";
  93.       break;
  94.     case WSAEWOULDBLOCK:
  95.       lpszRetStr="socket marked as non-blocking and SO_LINGER set not 0";
  96.       break;
  97.     case WSAEADDRINUSE:
  98.       lpszRetStr="address already in use";
  99.       break;
  100.     case WSAECONNABORTED:
  101.       lpszRetStr="connection aborted";
  102.       break;
  103.     case WSAECONNRESET:
  104.       lpszRetStr="connection reset";
  105.       break;
  106.     case WSAENOTCONN:
  107.       lpszRetStr="not connected";
  108.       break;
  109.     case WSAETIMEDOUT:
  110.       lpszRetStr="connection timed out";
  111.       break;
  112.     case WSAECONNREFUSED:
  113.       lpszRetStr="connection refused";
  114.       break;
  115.     case WSAEHOSTDOWN:
  116.       lpszRetStr="host down";
  117.       break;
  118.     case WSAENETUNREACH:
  119.       lpszRetStr="network unreachable";
  120.       break;
  121.     case WSAEHOSTUNREACH:
  122.       lpszRetStr="host unreachable";
  123.       break;
  124.     case WSAEADDRNOTAVAIL:
  125.       lpszRetStr="address not available";
  126.       break;
  127.     default:
  128.       if(lpszBuf==NULL) lpszBuf=szErrMsg;
  129.       wsprintf((LPSTR)lpszBuf, (LPSTR)"error %u", nErr);
  130.       return(lpszBuf);
  131.   }
  132.   if(lpszBuf!=NULL) {
  133.     lstrcpy(lpszBuf,lpszRetStr);
  134.     return(lpszBuf);
  135.   }
  136.   return(lpszRetStr);
  137. }
  138.  
  139. VOID ReportWSError(UINT nErr)
  140. {
  141.   DoAddLine(ReturnWSError(nErr,NULL));
  142. }
  143.  
  144.